public class Main {
    public static void main(String[] args) {
        System.out.println("Hello world!");
        Solution solution = new Solution();
        String ret = solution.intToRoman(1994);
        System.out.println(ret);
    }
}


class IntRomanPair{
    int num;
    String roman;
    IntRomanPair(int num, String roman){this.num = num; this.roman = roman;}
}

class Solution {
    public String intToRoman(int num) {
        IntRomanPair[] intRomanPairs = {
                new IntRomanPair(1000, "M"),
                new IntRomanPair(900, "CM"),
                new IntRomanPair(500, "D"),
                new IntRomanPair(400, "CD"),
                new IntRomanPair(100, "C"),
                new IntRomanPair(90, "XC"),
                new IntRomanPair(50, "L"),
                new IntRomanPair(40, "XL"),
                new IntRomanPair(10, "X"),
                new IntRomanPair(9, "IX"),
                new IntRomanPair(5, "V"),
                new IntRomanPair(4, "IV"),
                new IntRomanPair(1, "I")
        };

        StringBuilder ret = new StringBuilder();
        for(IntRomanPair intRomanPair: intRomanPairs){
            while (num >= intRomanPair.num){
                num -= intRomanPair.num;
                ret.append(intRomanPair.roman);
            }
        }

        return ret.toString();
    }
}